package com.ita.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ita.annotation.ServiceLog;
import com.ita.dao.FoodDao;
import com.ita.dao.FoodTypeDao;
import com.ita.dao.impl.FoodDaoImpl;
import com.ita.dao.impl.FoodTypeDaoImpl;
import com.ita.pojo.Food;
import com.ita.pojo.FoodType;
import com.ita.service.FoodService;

@Service(value = "foodService")
public class FoodServiceImpl implements FoodService {

	@Resource(name = "foodDao")
	private FoodDao foodDao;

	@Resource(name = "foodTypeDao")
	private FoodTypeDao foodTypeDao;

	@Override
	@Transactional
	@ServiceLog(description="add food")
	public Food addFood(Food food) {
		return foodDao.add(food);
	}

	@Override
	@Transactional
	@ServiceLog(description="del food")
	public Food deleteFood(String id) {
		return foodDao.delete(id);
	}

	@Override
	@Transactional
	@ServiceLog(description="update food")
	public Food updateFood(Food food) {
		return foodDao.update(food);
	}

	@Override
	@ServiceLog(description="load food by id")
	public Food loadFoodById(String id) {
		return foodDao.select(id);
	}

	@Override
	@ServiceLog(description="find all")
	public List<Food> findAll(String m_id) {
		return foodDao.findAll(m_id);
	}

	@Override
	@ServiceLog(description="load food by type")
	public List<Food> loadFoodByType(String type) {
		return foodDao.loadFood(type);
	}

	@Override
	@Transactional
	@ServiceLog(description="add food type")
	public FoodType addFoodType(FoodType type) {
		return foodTypeDao.add(type);
	}

	@Override
	@ServiceLog(description="load add food type")
	public List<FoodType> loadFoodType() {
		return foodTypeDao.loadFoodType();
	}

	@Override
	@ServiceLog(description="load food type by id")
	public FoodType loadFoodType(String id) {
		return foodTypeDao.select(id);
	}

}
